import { request } from '@/utils/request';
import { TimerDTO, TimerVO } from '@/types/timer';

const BASE_URL = '/api/timers';

export async function getTimers(): Promise<TimerVO[]> {
  return request.get(BASE_URL);
}

export async function getTimerById(id: number): Promise<TimerVO> {
  return request.get(`${BASE_URL}/${id}`);
}

export async function createTimer(data: TimerDTO): Promise<TimerVO> {
  return request.post(BASE_URL, data);
}

export async function updateTimer(id: number, data: TimerDTO): Promise<TimerVO> {
  return request.put(`${BASE_URL}/${id}`, data);
}

export async function deleteTimer(id: number): Promise<void> {
  return request.delete(`${BASE_URL}/${id}`);
}

export async function toggleTimerStatus(id: number): Promise<TimerVO> {
  return request.put(`${BASE_URL}/${id}/toggle`);
} 